package com.zj.business.pdfInfo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zj.business.pdfInfo.domain.PdfInfo;
import com.zj.business.pdfInfo.mapper.PdfInfoMapper;
import com.zj.business.pdfInfo.service.IPdfInfoService;
import com.zj.business.reader.PdfReaderContext;
import com.zj.business.reader.impl.PdfBoxReader;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.Executor;

/**
 * @author zhangbo
 * @program: PDF-helper
 * @ClassName PdfInfoServiceImpl
 * @description: $
 * @date 2023-05-17 22:06:07
 */
@Slf4j
@Service
public class PdfInfoServiceImpl extends ServiceImpl<PdfInfoMapper, PdfInfo> implements IPdfInfoService {

    @Autowired
    private PdfReaderContext pdfReaderContext;
    @Autowired
    private Executor threadPoolExecutor;


    @Override
    public void testSync() {

        threadPoolExecutor.execute(() -> {
            log.info("线程池----------异步");
            log.info("线程池----------异步");
            log.info("线程池----------异步");
            log.info("线程池----------异步");
            log.info("线程池-----结束-----异步");
        });

    }

    @Override
    public String testReadPdf() {
        pdfReaderContext.setPdfReader(new PdfBoxReader());
        return pdfReaderContext.executeOperation("");
    }
}
